#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"

int main() {
    int p1[2], p2[2];
    char argv;
    int pid;
    pipe(p1);
    pipe(p2);

    if(fork() == 0) {
        pid = getpid();
        read(p1[0], &argv, 1);
        printf("%d: received ping\n", pid);
        close(p1[0]);
        write(p2[1], &argv, 1);
        close(p2[1]);
        exit(0);
    } else {
        pid = getpid();
        write(p1[1], "o", 1);
        close(p1[1]);
        read(p2[0], &argv, 1);
        printf("%d: received pong\n", pid);
        close(p2[0]);
    }
    exit(0);
}